<!--{template /module/admin/view/head}-->
<div id="left_layout">
	<div id="main_content" class="container-fluid">
	<!--{template /module/admin/view/head_nav}-->
		<div class="row-fluid">
			<div class="well widget">
				<div class="widget-header">
					<h3 class="title">{lang user.sms.list.view.header}</h3>
				</div>
				<div class="widget-content">
					<form class="form-search" id="frm_search" name="frmSearch" action="{$ADMIN_SCRIPT}/user/sms" method="post">
					<div class="action-wrapper">
						<div class="pull-left">
							<a href="javascript:void(null);" id="btn_delete_list" class="btn btn-small" {$dispatches[operations][delete]}>{lang admin.operation.delete}</a>
							<a href="{$ADMIN_SCRIPT}/user/sms/_add" {$dispatches[operations][add]} class="btn btn-small">{lang user.sms.list.view.operation.add}</a>
						</div>
						<div class="pull-right" {$dispatches[operations][search]}>
							<div class="input-append" >
								<input type="text" name="txtKeyword" value="{$_var[gp_txtKeyword]}" class="input-small search-query" />
								<button type="submit" class="btn">{lang admin.search.submit}</button>
							</div>
							<button type="button" state="0" class="btn" id="btn_extend_search">{lang admin.search.submit.extend}<i class="micon-arrow-down"></i></button>
						</div>
					</div>
					</form>
					
					<div id="div_extend_search" style="display:none;">
						<hr/>
						<form id="frm_extend_search" name="frmExtendSearch" action="{$ADMIN_SCRIPT}/user/sms" method="post">
						<input type="hidden" name="hdnSearchShow" id="hdnSearchShow" value="1" />
						<table>
						<tr>
							<td width="46">{lang admin.search.keyword}</td>
							<td>
								<label class="checkbox inline">
									<input type="text" name="txtKeyword" value="{$_var[gp_txtKeyword]}" class="input-medium" />
								</label>
								<label class="checkbox inline">
								<select name="sltType">
								<option value="0" {if $_var['gp_sltType'] == 0}selected="selected"{/if}>{lang user.sms.list.view.search.type.select.0}</option>
						            <option value="1" {if $_var['gp_sltType'] == 1}selected="selected"{/if}>{lang user.sms.list.view.search.type.select.1}</option>
						            <option value="2" {if $_var['gp_sltType'] == 2}selected="selected"{/if}>{lang user.sms.list.view.search.type.select.2}</option>
					            </select>
				            	</label>
							</td>
						</tr>
						<tr>
							<td>{lang admin.search.time}</td>
							<td>
								<input type="text" name="txtBeginDate" maxlength="16" class="input-medium input-date" value="{$_var[gp_txtBeginDate]}" />
					            {lang admin.search.to}
					            <input type="text" name="txtEndDate" maxlength="16" class="input-medium input-date" value="{$_var[gp_txtEndDate]}" />
							</td>
						</tr>
						<tr>
							<td></td>
							<td>
								<button type="submit" class="btn btn-primary">{lang admin.search.submit.extend.submit}</button>
							</td>
						</tr>
						</table>
						</form>
					</div>
					
					<hr/>
					<form id="frm_grid" name="frmGrid" action="{$ADMIN_SCRIPT}/user/sms&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}" method="post">
					<table class="table table-hover">
						<thead>
						 	<tr>
								<th width="30"><input type="checkbox" class="fancy" name="cbxAll"/></th>
								<th width="120">{lang user.sms.list.view.th.mobile}</th>
					        	<th>{lang user.sms.list.view.th.message}</th>
					        	<th width="100">{lang user.sms.list.view.th.type}</th>
					        	<th width="160">{lang user.sms.list.view.th.createtime}</th>
					        	<th width="50">{lang user.sms.list.view.th.times}</th>
					        	<th width="120">{lang user.message.list.view.th.operation}</th>
							</tr>
						</thead>
						<tbody>
						<!--{loop $smses $_loop $sms}-->
							<tr class="item-row">
								<td>
						        	<input type="checkbox" class="fancy" name="cbxItem[]" title="{$sms[MOBILE]}" value="{$sms[SMSID]}" />
		           				</td>
					            <td class="f16">{$sms[MOBILE]}</td>
					            <td>{$sms[MESSAGE]}</td>
					            <td>
					            	<!--{if $sms['STATUS']}-->
					            	{lang user.sms.list.view.td.status.no}
					            	<!--{else}-->
					            	{lang user.sms.list.view.td.status.yes}
					            	<!--{/if}-->
					            </td>
					            <td>{$sms[CREATETIME]}</td>
					            <td>{$sms[TIMES]}</td>
					            <td class="center">
					            	<a class="btn btn-mini btn-delete" mobile="{$sms[MOBILE]}" data="{$sms[SMSID]}" href="javascript:void(null);" {$dispatches[operations][delete]}>{lang admin.operation.delete}</a>	
					            	<!--{if $sms['STATUS']}-->
						          	<a class="btn btn-mini btn-primary btn-send" mobile="{$sms[MOBILE]}" data="{$sms[SMSID]}" href="javascript:void(null);" {$dispatches[operations][edit]}>{lang user.sms.list.view.td.button.send}</a>	            
						            <!--{/if}-->
					            </td>
       					 	</tr>
        				<!--{/loop}-->
        				<!--{if $count == 0}-->
        				<tr>
	            			<td colspan="7">
	               				 * {lang admin.operation.empty}
	           				</td>
        				</tr>
        				<!--{/if}-->   
						</tbody>
					</table>
					</form>
					
					<hr/>
					{$pager}
				</div>
			</div>
		</div>
	</div>
</div>

<script>
function search_toggle(){
	var state = $('#btn_extend_search').attr('state');
	if(state == '0'){
		$('#btn_extend_search').html('{lang admin.search.submit.extend.hide}<i class="micon-arrow-up"></i>').attr('state', '1');
	}else{
		$('#btn_extend_search').html('{lang admin.search.submit.extend}<i class="micon-arrow-down"></i>').attr('state', '0');
	}
	
	$('.pull-right .input-append').toggle();
	$('#div_extend_search').toggle();
}

$(function(){
	$('.fancy').uniform();
	$('.input-date').datepicker({format:'yyyy-mm-dd'});
	
	$('#btn_delete_list').click(function(){
		if($("#frm_grid input[name='cbxItem[]']:checked").length > 0){
			$.dialog({submit:'{lang admin.operation.delete}', message:'<p>{lang user.sms.list.view.operation.delete.message}</p>', callback:function(){
				$('#modal_dialog .btn-primary').click(function(){
					$('#frm_grid').attr('action', "{$ADMIN_SCRIPT}/user/sms&do=delete_list&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}");
					$('#frm_grid').submit();
				});
			}});
		}else $.dialog({message:'{lang user.sms.list.view.operation.empty}'});
	});
	
	$('#btn_extend_search').click(function(){
		search_toggle();
	});
	
	$("#frm_grid input[name='cbxAll']").click(function(){
		if(this.checked){
			$('#frm_grid .item-row').addClass('warning');
			$("#frm_grid input[name='cbxItem[]']").attr('checked', true).parent().addClass('checked');
		}else{
			$('#frm_grid .item-row').removeClass('warning');
			$("#frm_grid input[name='cbxItem[]']").attr('checked', false).parent().removeAttr('class');
		}
	});
	
	$("#frm_grid input[name='cbxItem[]']").click(function(){
		if(this.checked) $(this).parent().parent().parent().parent().addClass('warning');
		else $(this).parent().parent().parent().parent().removeClass('warning');
	});
	
	$('#frm_grid .btn-delete').click(function(){
		var smsid = $(this).attr('data');
		
		$.dialog({submit:'{lang admin.operation.delete}', message:'<p>{lang user.sms.list.view.operation.delete.message}</p>', callback:function(){
			$('#modal_dialog .btn-primary').click(function(){
				$('#frm_grid').attr('action', "{$ADMIN_SCRIPT}/user/sms&do=delete&id=" + smsid + "&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}");
				$('#frm_grid').submit();
			});
		}});
	});
	
	$('#frm_grid .btn-send').click(function(){
		var smsid = $(this).attr('data');
		var mobile = $(this).attr('mobile');
		
		$.dialog({submit:'{lang user.sms.list.view.operation.send.button}', message:'<p>{lang user.sms.list.view.operation.send.message1}'+ mobile +'{lang user.sms.list.view.operation.send.message2}</p>', callback:function(){
			$('#modal_dialog .btn-primary').click(function(){
				$('#frm_grid').attr('action', "{$ADMIN_SCRIPT}/user/sms&do=send&id=" + smsid + "&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}");
				$('#frm_grid').submit();
			});
		}});
	});
	
	{if $_var[gp_hdnSearchShow]}
	search_toggle();
	{/if}
});
</script>
<!--{template /module/admin/view/foot}-->